import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  UseGuards,
  Query,
} from '@nestjs/common';
import { UserService } from './user.service';
import { CreateNormalUserDto } from './dto/create-normal-user.dto';
import { UpdateUserDto } from './dto/update-user.dto';
import { LoginDto } from './dto/login-dto';
import { AuthGuard } from '@nestjs/passport';
@UseGuards(AuthGuard('jwt'))
@Controller('user')
export class UserController {
  constructor(private readonly userService: UserService) {}

  @Post('register')
  async register(@Body() createUserDto: CreateNormalUserDto) {
    return await this.userService.register(createUserDto);
  }

  @Post('login')
  login(@Body() data: LoginDto) {
    return this.userService.login(data);
  }

  @Get('logout')
  logout() {
    return this.userService.logout();
  }
  @Get()
  async findAll(
    @Query('pageNum') pageNum: number,
    @Query('pageSize') pageSize: number,
    @Query('username') username: number,
    @Query('email') email: number,
  ) {
    return this.userService.findAll(pageNum, pageSize, username, email);
  }
}
